/*
 * @Author: your name
 * @Date: 2021-03-29 08:57:23
 * @LastEditTime: 2021-04-23 14:11:41
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \active-front\src\router\index.js
 */
import Vue from "vue";
import Router from "vue-router";
import Login from "../components/users/login"; //登录
import Reg from "../components/users/reg.vue";
import Info from "@/components/info"; //主界面
import Home from "../components/Home/index.vue"; //首页
import HotEvents from "../components/Hotevents/index.vue"; //热门活动
import ActivityDetails from "../components/Hotevents/details/index.vue"; //活动详情
// import UploadIcon from "../components/UploadIcon/index.vue"; //上传文件
import Personal from "../components/Personal/index.vue"; //个人中心
import Information from "../components/Personal/information/index.vue"; //个人信息
import SignedUp from "../components/Personal/SignedUp/index.vue"; //已报名活动
import Modify from "../components/Personal/Modify"; // 修改个人信息
import Privacy from "../components/Personal/Privacy"; //隐私修改密码修改
import Textpage from "../components/Personal/Textpage"; //测试页面
import Seacher from "../components/Hotevents/seacher"; //使用导航栏标签进行查列表 为使用状态机 后续优化可以考虑
import FindEnrollUsers from "../components/Personal/findEnrollUsers";
import HomeHotEvents from "../components/HomeHotevents"; //主页数据
import ActivelyModify from "../components/Personal/ActivelyModify";
import ActMap from "../components/Map/index.vue"; //地图
import NewsDetail from "../components/Hotevents/newsDetail/index.vue";
import Notfound from "../components/Notfound"; //404

Vue.use(Router);
//阻止重复路由报错
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

export default new Router({
  routes: [
    {
      path: "/",
      redirect: "/login"
    },
    {
      path: "/login",
      name: "Login",
      component: Login
    },
    {
      path: "/login/:id",
      name: "LoginId",
      component: Login
    },
    {
      path: "/reg",
      name: "Reg",
      component: Reg
    },
    {
      path: "/info",
      name: "info",
      redirect: "/info/home",
      component: Info,
      children: [
        { path: "homeHomeHotevents", component: HomeHotEvents },
        { path: "home", component: Home },
        { path: "seacher/:id", component: Seacher },

        {
          path: "activity",
          component: HotEvents
        },
        {
          path: "activity/:id",
          component: ActivityDetails
        },
        // {
        //   path: "uploadIcon",
        //   component: UploadIcon
        // },
        {
          path: "personal",
          redirect: "/info/personal/information",
          component: Personal,
          children: [
            {
              path: "activelydetail",
              component: ActivelyModify
            },
            {
              path: "information",
              component: Information
            },
            { path: "signedup", component: SignedUp },
            {
              path: "modify",
              component: Modify
            },
            {
              path: "privacy",
              component: Privacy
            },
            {
              path: "textpage",
              component: Textpage
            },
            {
              path: "findenrolluser",
              component: FindEnrollUsers
            }
          ]
        },
        {
          path: "map",
          component: ActMap
        },
        {
          path: "newsDetail",
          component: NewsDetail
        }
      ]
    },
    // 最后是404页面
    {
      path: "*",
      redirect: "/Notfound"
    },
    {
      path: "/Notfound",
      component: Notfound
    }
  ]
});
